<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.commons.SessionKeys,
                 com.scalar.chiptrack.utils.ConfigManager,
				 com.scalar.chiptrack.commons.Constants,
				 com.scalar.chiptrack.users.Functionality,
				 com.scalar.chiptrack.users.User"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/sortRelease.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet"></HEAD>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/assembly_release.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>

<SCRIPT language="JavaScript">
window.onload=init;

function init()
{
    qs_1 = new QuickSearch(document.sortReleaseForm['sortRelease.processStepId'], document.sortReleaseForm.qs1, false);
}

function generateSortRelease( index )
{
    var errors = ""
	if( typeof ( document.sortReleaseForm.lotId.value )  != 'undefined' )
	{
		if( document.sortReleaseForm.shipToVendorId.value == -1 )
		{
			errors = "<li>Select Ship To Vendor to generate Sort Release";
		}
        else if( document.sortReleaseForm.shipperId.value == -1 )
        {

            errors = errors + "<li>Select Shipper to generate Sort Release";
        }
		if( errors != "" )
        {
            var pa=document.getElementById("errors");
			pa.innerHTML = errors;
        }
        else
		{
            var lotId = document.sortReleaseForm.lotId.value;
            var processStepId = document.sortReleaseForm.processStepId.value;
            var shipToVendorId = document.sortReleaseForm.shipToVendorId.value;
            var vendorId = document.sortReleaseForm.vendorId.value;
            var shipperId = document.sortReleaseForm.shipperId.value;
		    document.sortReleaseForm.action = '<%=chipTracContext%>/sortRelease.do?action=create&vendorId='+vendorId+'&lotId='+lotId+'&processStepId='+processStepId+'&shipToVendorId='+shipToVendorId+'&shipperId='+shipperId;
            document.sortReleaseForm.submit();
		}
	}
	else
	{
        if( document.sortReleaseForm.shipToVendorId[index].value == -1 )
		{
			errors = "<li>Select Ship To Vendor to generate Sort Release";
		}
        if( document.sortReleaseForm.shipperId[index].value == -1 )
        {
            errors =  errors + "<li>Select Shipper to generate Sort Release";
        }
        if( errors != "" )
        {
            var pa=document.getElementById("errors");
			pa.innerHTML = errors;
        }
		else
		{
		    var lotId = document.sortReleaseForm.lotId[index].value;
            var processStepId = document.sortReleaseForm.processStepId[index].value;
            var shipToVendorId = document.sortReleaseForm.shipToVendorId[index].value;
            var vendorId = document.sortReleaseForm.vendorId[index].value;
            var shipperId = document.sortReleaseForm.shipperId[index].value;
		    document.sortReleaseForm.action = '<%=chipTracContext%>/sortRelease.do?action=create&vendorId='+vendorId+'&lotId='+lotId+'&processStepId='+processStepId+'&shipToVendorId='+shipToVendorId+'&shipperId='+shipperId;;
            document.sortReleaseForm.submit();
		}
	}
}
function search()
{
     document.sortReleaseForm.action = '<%=chipTracContext%>/sortRelease.do?action=searchforLots';
     document.sortReleaseForm.submit();
}

function reset()
{
    document.sortReleaseForm.reset();
    qs_1.resetQuickSearchCntrl();    
}

</SCRIPT>

<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
	<TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

	<!-- Side Navigation start -->
	<%@ include file="/jsp/operations/releaseMenu.jsp" %></TD>
	<!-- end of the side navigations -->

	<TD bgcolor="#ffffff">
	<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	<TD valign="top" width="100%">

	<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	<BR>

	<html:form action="/sortRelease.do" method="POST" onsubmit="javascript:return search();" type="com.scalar.chiptrack.operations.release.forms.SortReleaseForm">
    <nested:nest property="sortRelease" >
		<TABLE width="70%" align="center" cellpadding="2" cellspacing="2" border="0">
			<TR><TD colspan="4" class="NArialW" align="center">Wafer Sort Release</TD></TR>

			<TR><TD colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></TD></TR>
			<TR><TD colspan='4' class="NArialL"><chiptrack:errors styleClass="NArialL"/></TD></TR>
			<TR><TD colspan='4' class="NArialL"><chiptrack:info styleClass="NArialL"/></TD></TR>
			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr>
            <td class="NArialL" nowrap>
            Quick Search Part Number:
            </td>
            <td class="NArialL">
            <input type="text" name="qs1" class="txfield" size='18' onkeyup='quickSearch(qs_1)'/>
            </td>
            <td colspan='2'>
            </tr>

            <tr>
			<td class="NArialL" width="20%" nowrap>
				Part Number:
			</td>
			<td class="NArialL" width="30%">
			<nested:select property="processStepId"  styleClass="txfield">
                <html:option value="-1">All Part Numbers</html:option>
				<html:options collection="partNumberList" property="value" labelProperty="label"/>
			</nested:select>
			</td>
			<td class="NArialL" width="20%" nowrap>
				Wafer Store Vendor:
			</td>
			<td class="NArialL" width="30%">
			<nested:select property="vendorId"  styleClass="txfield">
                <html:option value="-1">All Wafer Store Vendors</html:option>
				<html:options collection="fromLocationList" property="value" labelProperty="label"/>
			</nested:select>
			</td>
			</tr>
			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='5'></TD></TR>
			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
			<tr>
				<td colspan="5" align="center">
                 <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" onclick="javascript:return search()" width="53" height="17" onmouseover="window.status='Click to Search for Wafer Sort Release';return true" onmouseout="window.status='';return true" title="Click here to Search for Wafer Sort Release">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="javascript:reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
				</td>
			</tr>
            <logic:present name="LotsList" scope="request">
            <TR>
                <TD colspan='4'>
                    <table width="100%" align="left" cellpadding="2" cellspacing="2" border="0">
                        <tr>
                            <td width="15%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Part Number</font>
                            </td>
                            <td width="20%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Base Product Name</font>
                            </td>
                            <td width="15%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Wafer Store <br>Vendor</font>
                            </td>
                            <td width="15%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Lot Number</font>
                            </td>
                            <td width="15%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Ship To Vendor</font>
                            </td>
                            <td width="15%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Shipper</font>
                            </td>
                            <td width="15%" class="NArialL" bgcolor="#993333" nowrap align="center">
                                <font color="#FFFFFF">Qty Available</font>
                            </td>
                            <td width="25%" class="NArialL" bgcolor="#993333" nowrap align="center">
                               <font color="#FFFFFF"> Actions</font>
                            </td>
                        </tr>
                        <logic:iterate name="LotsList" id="sortRelease"  indexId="iteratorIdx" >
                            <tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                <td width="15%" class="NArialL" nowrap>
                                    &nbsp;<bean:write name="sortRelease" property="partNumber" />
                                </td>
                                <td width="20%" class="NArialL">
                                    &nbsp;<bean:write name="sortRelease" property="baseProductName" />
                                </td>
                                <td width="15%" class="NArialL" nowrap>
                                    <bean:write name="sortRelease" property="vendName" />
                                </td>
                                <td width="15%" class="NArialL" nowrap>
                                    <bean:write name="sortRelease" property="lotNumber" />
                                </td>
                                <td width="15%" class="NArialL" nowrap>
                                    <html:select name="sortRelease" property="shipToVendorId"  styleClass="txfield">
                                        <html:option value="-1">--Select--</html:option>
                                        <html:options collection="shipToLocationList" property="value" labelProperty="label"/>
                                    </html:select>
                                </td>
                                <td width="15%" class="NArialL" nowrap>
                                    <html:select name="sortRelease" property="shipperId"  styleClass="txfield">
                                        <html:option value="-1">--Select--</html:option>
                                        <html:optionsCollection name="sortRelease" property="shippersList" value="value" label="label"/>
                                    </html:select>
                                </td>
                                <td width="15%" align='right' class="NArialL">
                                    <bean:write name="sortRelease" property="qtyAvailable" />
                                </td>
                                <html:hidden name='sortRelease' property="vendorId" />
                                <html:hidden name='sortRelease' property="processStepId" />
                                <html:hidden name='sortRelease' property="lotId" />
                                <td width="25%" class="NArialL" align="center">
                                    <a href='javascript:generateSortRelease(<bean:write name="iteratorIdx"/>)' onMouseOver="window.status='Click to Generate Sort Release';return true" onMouseout="window.status='';return ">Generate</a>&nbsp;
                                </td>
                            </tr>
                        </logic:iterate>
                    </table>
                </TD>
           </TR>
           </logic:present>
		</TABLE>
        </nested:nest>
	</html:form>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>